import request from '@/utils/request'
/**
 * 获取员工列表
 * @param {*} params
 * @returns
 */
export function getEmployeesListAPI (params) {
  return request({
    url: '/sys/user',
    method: 'GET',
    params
  })
}

/**
 * 删除员工信息
 * @param {*} id
 * @returns
 */
export function delEmployeeAPI (id) {
  return request({
    url: `/sys/user/${id}`,
    method: 'DELETE'
  })
}

/**
 * 新增员工
 * @param {*} emObj
 * @returns
 */
export function addEmployeesAPI (emObj) {
  return request({
    url: '/sys/user',
    method: 'POST',
    data: emObj
  })
}
/**
 * 批量导入
 * @param {*} data
 * @returns
 */
export function importEmployeeAPI (data) {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}
/**
 * 根据id修改员工信息
 * @param {*} emObj
 * @returns
 */
export function updateEmployeesAPI (emObj) {
  return request({
    url: `/sys/user/${emObj.id}`,
    method: 'PUT',
    data: emObj
  })
}

/**
 * 给员工分配角色
 * @param {*} data {id:员工id,rolelds:角色id}
 * @returns Promise对象
 */
export function saveEmployeesRoleAPI (data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
